<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/pages/common/component.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>新增支出记录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<script type="text/javascript">

	$(document).ready(function() {
  		// 时间初始化
  		configDate('feeDate', '<fmt:formatDate value="<%=new Date() %>" pattern="yyyy-MM-dd" type="date"/>', 'yy-mm-dd');
  		// 校验主表单
   	 	$("#feeForm").validationEngine();
  	});


function changeFeeSubType(feeTypeId){
	if(feeTypeId==''){
		alert('请选择费用类型');
		return ;
	}
	$.ajax({
	    url: 'feeTypeAction.do?method=getFeeSubType4Ajax&feeTypeId='+feeTypeId,
	    type: 'GET',
	    dataType: 'json',
	    cache: false,
	    error: function(){
	        alert('Error loading XML document');
	    },
	    success: function(json){
	    	var feeTypeOption = $("#feeTypeId option:first-child");
	    	if(feeTypeOption.attr("value") == ""){
	    		feeTypeOption.remove();
	    	}
	    	
	    	$("#feeSubTypeId").empty();
	    	$.each(json,function(idx,obj){
	    		$("#feeSubTypeId").append("<option value='"+obj.feeTypeId+"'>"+obj.feeTypeName+"</option>");
	    	})
	    	$("#feeTypeId").attr("style","width:30%");
	    	$("#feeSubTypeId").attr("style","width:30%");
	    }
	});
}

// 返回费用列表
function back2list(){
	if(confirm("数据没有保存!确认将丢失当前表单数据!")){
		window.location.href = "feeAction.do?method=list"
	}else{
		return ;
	}
}

</script>	

  </head>

  <body>
   <html:form method="post" styleId="feeForm" action="feeAction.do">
    <input type="hidden" name="method" value="insert"/>
    <br/><br/><br/><br/>
    <table width="40%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
		<tr align="center" bgcolor="#FAFAF1" height="22">
			<td colspan="2">
				<c:if test="${feeType == 0}">
					<b>新增支出</b>
				</c:if>
				<c:if test="${feeType == 1}">
					<b>新增收入</b>
				</c:if>
				<input type="hidden" name="feeType" value="${feeType }"/>
			</td>
		</tr>
		<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			<td width="10%">费用类型</td>
			<td width="30%">
				<select class="validate[required]" id="feeTypeId" name="feeTypeId" onchange="changeFeeSubType(this.value)" style='width:30%;'>
					<option value="">请选择</option>
					<c:forEach var="feeType" items="${lstFeeTypeVOs}">
						<option value="${feeType.feeTypeId }">${feeType.feeTypeName }</option>
					</c:forEach>	
				</select>
			</td>
		</tr>
		<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			<td>费用子类</td>
			<td>
				<select class="validate[required]" name="feeSubTypeId" id="feeSubTypeId" style='width:30%;'>
					<option value="">请选择</option>
				</select>
			</td>
		</tr>
		<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			<td>消费日期</td>
			<td>
				<input id="feeDate" name="feeDate" style='width:30%;' readonly/>
			</td>
		</tr>
		<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			<td>账户</td>
			<td>
				<select class="validate[required]" id="accountId" name="accountId" style='width:30%;' >
					<c:forEach var="account" items="${lstAccountVOs}">
						<option value="${account.accountId }">${account.accountName}:${account.amount}</option>
					</c:forEach>	
				</select>
			</td>
		</tr>
		<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			<td>金额</td>
			<td>
				<input class="validate[required,custom[number]]" id="amount" name="amount" style='width:30%;'/>
			</td>
		</tr>
		<c:if test="${feeType == 0}">
			<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td>报销</td>
				<td>
					<select name="isReturn" style='width:30%;'>
						<option value="0" selected >不可退回</option>
						<option value="1">可以退回</option>
					</select>
				</td>
			</tr>
		</c:if>	
		<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
			<td>备注</td>
			<td>
				<input name="note" style='width:30%;'/>
			</td>
		</tr>
		<c:if test="${feeType == 0}">
			<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
				<td>
					是否分账
				</td>
				<td>
					<select name="splitType" id="splitType" style='width:30%;'>
						<option value="">**不分帐**</option>
						<option value="month2day">当月－日分</option>
						<option value="year2month">当年－月分</option>
					</select>
				</td>
			</tr>
		</c:if>
		<tr>
			<td colspan="2" align="center">
				<html:submit value="提交"></html:submit>
				&nbsp;&nbsp;&nbsp;
				<input type="button" value="返回" onclick="back2list();"> 
			</td>
		</tr>
    </table>
   </html:form> 
    
  </body>
</html>
